<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;

}
html{
    font-size: 32vw;
}
body{
    font-size: 0.13rem;
    font-family: "微软雅黑"
}
html,body{
    height: 100%;
}
#header{
    position: fixed;
    top: 0;
    height:0.42rem;
    width: 100%;
    background-color: rgb(29,109,255);
   /* overflow: hidden; */
    position: relative;
    padding: 0.04rem;
    
    display: flex;
    justify-content: space-between;

}
#header .logo{
    padding: 0.06rem 0;
    width: 75%;
    margin-left: 0.04rem;
}
#header .logo>a>img{
    height: 0.21rem;
    vertical-align: middle;
}
/* a:hover{
    color: #ccc;
}  */
#header .app img{
    height: 0.28rem;
    padding: 0.04rem;
    vertical-align: middle;

}
#search{
    background-color: #fff;
    border-bottom: 1px solid #ccc;
    width: 100%;
    position: relative;
    
}
#search .searchbox{
    padding: 0.08rem;
    
}
#search .searchbox input{
    height: 0.25rem;
    width: 90%;
    padding-left: 5%;
    border-radius: 0.13rem;
    background-color: #f1f1f1;
    border: none;
    font-size: 0.13rem;

}
input{
    outline: none;
}
#search .button > button {
    width: 0.53rem;
    height: 0.25rem;
    background: #1d6dff;
    border-radius: 0.13rem;
    position: absolute;
    right: 0.08rem;
    top: 0.08rem;
    border: none;
}
#search .button > button::before {
    content: '搜索';
    height: 0.25rem;
    line-height: 0.25rem;
    font-size: 0.13rem;
    border: none;
    color: #fff;
}
/* 顶部 */

/* 主体 */
#pannels{
    width: 100%;
}
.pannels{
    width: 100%;
    padding-bottom: 0.17rem;
    background-color:#f5f5f5;
}
.pannels #oneLi{
    border-top: 1px solid #ddd ;
}
#oneLi .title{
    width: 95%;
    line-height: 0.33rem;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pannels #oneLi #twoUl{
    display: flex;
    flex-wrap: wrap;
   justify-content: flex-start;
   align-items: center;
   border-top: 1px solid #ccc;

   
}
#twoUl li{
    width: 25%;
    height: 0.33rem;
    line-height: 0.33rem;
    list-style: none;
    text-align: center;
    font-size: 0.11rem;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    /* margin: 0 10px; */

}
#twoUl li a{
    text-decoration: none;
    color: #666;
}

/* 底部 */
#footer {
    background-color: #f4f4f4;
    /* height: 100px; */
}
#footer > .more {
    height: 0.42rem;
    background-color: #f4f4f4;
    padding: 0.08rem;
}
#footer > .more > a {
    display: block;
    font-size: 0.11rem;
    line-height: 0.25rem;
    text-align: center;
    border-radius: 0.04rem;
    border: 1px solid #dddddd;
    background-image: linear-gradient(#ffffff, #f4f4f4);
    text-decoration: none;

}
#footer .chart {
    background-color: #1d6dff;
    margin-top: 0.08rem;
    margin-bottom: 0.05rem;
}
#footer .chart span {
    color: #fff;
    display: inline-block;
    font: bolder 0.15rem/0.29rem "Microsoft soft";
    padding-left: 0.08rem;
}
#footer .chart .mright img{
    width: 0.17rem;
    height: 0.17rem;
}
#footer .chart .mright{
    line-height: 0.33rem;
    padding-right: 0.17rem;
    float: right;
}
.login .container {
    padding: 0 ;
    margin: 0 auto;
}
#footer .row {
    height: 0.3rem;
    margin-top: 0.08rem;
    border-top: 1px solid #c4c4c4;
    border-bottom: 1px solid #c4c4c4;
    display: flex;
    justify-content: space-between;
    
    
}
#footer .row a {
    width: 33%;
    text-decoration: none;
}
#footer .row a div{
    height: 0.28rem;
    line-height: 0.28rem;
    text-align: center;
    font-size: 0.12rem;
    border-right: 1px solid #c4c4c4;
}

.content_b {
    text-align: center;
    padding: 0.08rem;
}
.content_b p {
    margin: 0 0 0.08rem;
    font-size: 0.11rem;
}
    </style>
  
</head>
<body>
    <!-- 顶部 -->
    <header id="header">
        <div class="logo">
            <a href="../index.html">
                <img src="	http://chst.vip:8081/for-stu/wfzh/images/header_logo.png" alt="">
            </a>
        </div>
        <div class="app">
            <a href="">
                <img src="http://chst.vip:8081/for-stu/wfzh/images/header_app.png" alt="">
            </a>
        </div>
    </header>

    <!-- 搜索栏 -->
    <main id="search">
        <div class="searchbox">
            <input type="text" name placeholder="请输入你想比价的产品">
        </div>
        <div class="button">
            <button></button>
        </div>
    </main>
    
    <!-- 频道 -->
    <main id="pannels">
        <ul id="accordion" class="pannels">
                <!-- <li id="oneLi">
                    <div class="title">
                        <span>大家电</span>
                        <i class="iconfont">▼</i>
                    </div>
                    <ul id="twoUl">
                        <li>笔记</li>
                        <li>超极</li>
                        <li>平板</li>
                        <li>上网</li>
                        <li>DVD</li>
                        <li>台式/电脑</li>
                        <li>一体机</li>
                        <li>多功能</li>
                        <li>酒柜/酒柜/酒柜</li>
                        <li>内存条/显示器</li>
                    </ul>
                </li> -->

        </ul>


    </main>
   
    
    <!-- 底部 -->
    <main id="footer">
        <div class="more">
            <a href="">更多优惠信息</a>
        </div>

        <div class="chart">
            <span>品牌排行</span>
            <span class="mright">
                <img src="http://chst.vip:8081/for-stu/wfzh/images/more.png" alt="">
            </span>
        </div>

        <div class="login">
            <div class="container">
                <div class="row">
                    <a href="">
                        <div>登入</div>
                    </a>
                    <a href="">
                        <div>注册</div>
                    </a>
                    <a href="javascript:scrollTo(0,0)">
                        <div>返回顶部</div>
                    </a>
                </div>
            </div>
            <div class="content_b">
                <p>
                    <a href="#">手机APP下载</a>
                    <a href="#">万峰智慧商城手机版</a>
                    " -- 掌上比价平台"
                </p>
                <p> chst.vip:8181/crm </p>
            </div>
        </div>
    </main>


    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script >
        // 获取 oneUl标签
        let oneUl = document.querySelector("#accordion")

        // 接收所有的 titleId
        let titleIdArr = []

        // 发送 请求获取一级分类的数据 并且渲染
        const xhr1 = new XMLHttpRequest()
        xhr1.open('get','http://chst.vip:1234/api/getcategorytitle',false)
        xhr1.onload = function(){
            if (xhr1.status === 200) {
                let res1 = JSON.parse(xhr1.responseText)
                // console.log(res1);

                let list = ''
                res1.result.forEach((item) => {
                    list += `
                    <li id="oneLi">
                        <div class="title" >
                            <span>${item.title}</span>
                            <i class="iconfont">▼</i>
                        </div>
                        <ul id="twoUl">

                        </ul>
                    </li>
             
                    `
                    // 给 titleIdArr数据 添加 titleId
                    titleIdArr.push(item.titleId)
                    // console.log(item);
                    
                oneUl.innerHTML = list
                });
                // console.log(oneUl);
                
            }
        }
        xhr1.send(null)

        // console.log(titleIdArr);
        // 获取 每一个 二级菜单标题 oneLi
        let twoUl = document.querySelectorAll('#twoUl')
        console.log(twoUl);
        // 发送请求 获取 二级分类的数据 并且 渲染
        titleIdArr.forEach((item,index)=>{
            const xhr2 = new XMLHttpRequest()
            xhr2.open('get',`http://chst.vip:1234/api/getcategory?titleid=${item}`,false)
            xhr2.onload = function(){
                if (xhr2.status === 200) {
                    let res2 = JSON.parse(xhr2.responseText)
                    console.log(res2);

                    let list = ''
                    res2.result.forEach((item)=>{

                        list += `
                        <li>
                            <a href="bijia.html?categoryid=${item.categoryId}">${item.category}</a>
                        </li>                    
                        `
                    })
                    twoUl[index].innerHTML = list
                    console.log(twoUl[index]);
                }
            }

            xhr2.send(null)
        })


        // 默认所有二级菜单收起
        $('#accordion>#oneLi>#twoUl').slideUp(0)
        // 点击标题 二级菜单展开
        $('#accordion>#oneLi').click(function(){
            $(this).find('#twoUl').slideToggle().parent().siblings().find('#twoUl').slideUp()
        })

    </script>

  
</body>
</html>